
#include <boost/test/unit_test.hpp>


#define _DEBUGING
#include "../AllocatorPoolBased.h"

#include <vector>
using namespace std;


class FixtureTestAllocatorPoolBased
{
public:

    static const int poolSize=1000;

    FixtureTestAllocatorPoolBased()
    :alloc(poolSize)
    {
        
        
    }

    AllocatorPoolBased<int> alloc;
};


BOOST_FIXTURE_TEST_CASE( TestAllocatorPoolBased_1, FixtureTestAllocatorPoolBased )
{
    for(int i=0;i<poolSize;i++)*alloc.allocate(1,NULL)=i;
    
}

BOOST_FIXTURE_TEST_CASE( TestAllocatorPoolBased_2, FixtureTestAllocatorPoolBased )
{
    static const int loops=10;
    
    for(int i=0;i<loops;i++)
    {
        int *pointers[poolSize];
        for(int j=0;j<poolSize;j++)pointers[j]=alloc.allocate(1,NULL);
        for(int j=0;j<poolSize;j++)*pointers[j]=0;
        for(int j=0;j<poolSize;j++)alloc.deallocate(pointers[j],1);
    }


}




BOOST_AUTO_TEST_CASE(TestAllocatorPoolBased_3)
{

   vector<int,AllocatorPoolBased<int> > vec;
   vec.push_back(1);
   BOOST_CHECK(vec.back()==1);
}






